﻿namespace Mercury.ParticleEngine
{
    using System;
    using System.Diagnostics.Contracts;

    /// <summary>
    /// Defines a random number generator that uses the standard .NET Framework System.Random type
    /// to generate random numbers.
    /// </summary>
    internal sealed class SystemRandomGenerator : IRandomGenerator
    {
        public SystemRandomGenerator()
            : this(new Random())
        {
        }

        public SystemRandomGenerator(Random random)
        {
            Contract.Requires<ArgumentNullException>(random != null);

            _random = random;
        }

        private readonly Random _random;

        public Int32 NextInteger()
        {
            return _random.Next();
        }

        public Single NextSingle()
        {
            return (Single)_random.NextDouble();
        }
    }
}